package com.cdxy.controller;


import com.cdxy.aop.ForceLogin;
import com.cdxy.biz.process.IUserSaveBizProcess;
import com.cdxy.model.dto.base.controller.BaseController;
import com.cdxy.model.dto.base.resp.ApiResponse;
import com.cdxy.model.dto.base.resp.BasePageResp;
import com.cdxy.model.dto.req.SaveHotelReq;
import com.cdxy.model.dto.req.SaveListReq;
import com.cdxy.model.dto.req.SavePostReq;
import com.cdxy.model.dto.req.SaveSceneReq;
import com.cdxy.model.dto.resp.SaveListResp;
import com.cdxy.util.AxUidUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户收藏表 前端控制器
 * </p>
 *
 * @author autoGenCode
 * @since 2020-03-05
 */
@RestController
@RequestMapping("/userSave")
@Api(tags = "用户收藏")
public class UserSaveController extends BaseController {

    @Autowired
    private IUserSaveBizProcess userSaveBizProcess;

    @Autowired
    private AxUidUtil axUidUtil;

    @PostMapping("/savePost")
    @ApiOperation(value = "收藏帖子", notes = "")
    @ForceLogin
    public ApiResponse savePost(@Validated @RequestBody SavePostReq savePostReq) {
        savePostReq.setAxUid(axUidUtil.getAxUid());
        userSaveBizProcess.savePost(savePostReq);
        return successApiResponse();
    }

    @PostMapping("/saveHotel")
    @ApiOperation(value = "收藏酒店", notes = "")
    @ForceLogin
    public ApiResponse saveHotel(@Validated @RequestBody SaveHotelReq saveHotelReq) {
        saveHotelReq.setAxUid(axUidUtil.getAxUid());
        userSaveBizProcess.saveHotel(saveHotelReq);
        return successApiResponse();
    }

    @PostMapping("/saveScene")
    @ApiOperation(value = "收藏景点", notes = "")
    @ForceLogin
    public ApiResponse saveScene(@Validated @RequestBody SaveSceneReq saveSceneReq) {
        saveSceneReq.setAxUid(axUidUtil.getAxUid());
        userSaveBizProcess.saveScene(saveSceneReq);
        return successApiResponse();
    }

    @GetMapping("/saveList")
    @ApiOperation(value = "收藏列表", notes = "")
    @ForceLogin
    public ApiResponse<BasePageResp<SaveListResp>> saveList(@Validated SaveListReq saveListReq) {
        saveListReq.setAxUid(axUidUtil.getAxUid());
        return successApiResponse(userSaveBizProcess.saveList(saveListReq));
    }
}
